<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
            <table border="1" cellpadding="0">
                <thead align="center">
                    <td>书名</td>
                    <td>借书时间</td>
                    <td>最后还书时间</td>
                    <td>作者</td>
                    <td>类别</td>
                </thead>
                <tbody align="center">
                <td width="80">java书</td>
                <td width="180">2021年4月10日 09：01</td>
                <td width="180">2021年5月10日 09：01</td>
                <td width="80">胡昆</td>
                <td width="80" >IT</td>
                </tbody>

            </table>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button id="close" type="button" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit="" lay-filter="user-save">
                <i class="layui-icon layui-icon-close"></i>
                关闭
            </button>

        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery'], function () {
        let form = layui.form;
        let $ = layui.jquery;

        form.on('submit(user-save)', function (data) {
            let roleIds = "";
            $('input[type=checkbox]:checked').each(function () {
                roleIds += $(this).val() + ",";
            });
            roleIds = roleIds.substr(0, roleIds.length - 1);
            data.field.roleIds = roleIds;

            $.ajax({
                url: '/system/user/save',
                data: JSON.stringify(data.field),
                dataType: 'json',
                contentType: 'application/json',
                type: 'post',
                success: function (result) {
                    if (result.success) {
                        layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
                            parent.layui.table.reload("user-table");
                        });
                    } else {
                        layer.msg(result.msg, {icon: 2, time: 1000});
                    }
                }
            })
            return false;
        });
        $("button").on("click",function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));//关闭当前页
        })
    })
</script>
<script>
</script>
</body>
</html>
